# -*- coding: utf-8 -*-
import numpy as np
import ga as ga
import time
def costFcn(x,params):
    import numpy as np
    for i in range(10000):
        g=np.array([0,0])
        f=100*(x[1]-x[0]**2)**2+(1-x[0])**2
        g[0]=2*x[0]-x[1]
        g[1]=1-x[0]
    return (f,g)
lb=np.array([-2.0,-5.0])
ub=np.array([3.0,5.0])
x=np.array([2.0,1.0])
f,g=costFcn(x,0.0)
GA=ga.ga(costFcn,lb,ub)

# denorm test
XNorm=np.random.rand(100,2)#np.array([[0.5,0.4],[1.0,1.0],[0.0,0.0]])
X=GA._denorm(XNorm)
time1=time.time()
F,G=GA._systemEval(X)
print "Single core time = ",time.time()-time1, "s"
#print " input X values = ",X
#print "output F values = ",F
#print "output G values = ",G

time2=time.time()
F,G=GA._systemEval_pp(X)
print "Multi  core time = ",time.time()-time2, "s"
#print " input X values = ",X
#print "output F values = ",F
#print "output G values = ",G

#GA._systemEval_mp(X)